package com.example.demo.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> jwtExcludePatterns = new ArrayList();
        //controller
        jwtExcludePatterns.add("/login/login");
        jwtExcludePatterns.add("/login/toLogin");
        jwtExcludePatterns.add("/login/register");
        jwtExcludePatterns.add("/login/toRegister");
        //页面
        jwtExcludePatterns.add("/security/login/**");
        jwtExcludePatterns.add("/system/**");
        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns(jwtExcludePatterns);
    }
}